<template>
  <div>
    <h2>One</h2>
    <p>count{{ count }}</p>
  </div>
</template>

<script>
import Pubsub from "pubsub-js";

export default {
name:"One",
data(){
 return{
    count:0
 }
},
 /* 
    订阅一般在初始化的时候就已经完成了,未来随时发布都可以
  */
 mounted(){
    Pubsub.subscribe("changeCount",(_,num)=>{
        this.count +=num
    })
 }
}
</script>

<style>

</style>